package com.pan.kang.flow.condition;

import com.pan.kang.constant.OrderType;
import com.pan.kang.dto.CreateOrderDto;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;

@LiteflowComponent(id = "orderType", name = "订单类型判断")
public class OrderTypeCondition extends NodeSwitchComponent {

    @Override
    public String processSwitch() throws Exception {
        CreateOrderDto createOrderDto = this.getContextBean(CreateOrderDto.class);
        if (OrderType.NORMAL.getValue().equals(createOrderDto.getOrderType())) {
            return OrderType.NORMAL.getValue();
        } else if (OrderType.CUSTOM.getValue().equals(createOrderDto.getOrderType())) {
            return OrderType.CUSTOM.getValue();
        } else if (OrderType.PRE_SALES.getValue().equals(createOrderDto.getOrderType())) {
            return OrderType.PRE_SALES.getValue();
        }
        throw new RuntimeException("没有此类型的订单！！！");
    }
}
